package com.dc.bobaoge.project.v3.to.v2.business.core.util;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dc.bobaoge.project.base.core.old.entity.OldCoreCerCerContact;
import com.dc.bobaoge.project.base.core.old.mapper.OldCoreCerCerContactMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * AuthenticationInfoUtil
 *
 * @author chenxueli
 * @date 2024-01-30 14:44:00
 */
@Slf4j
@Component
public class AuthenticationInfoUtil {

    @Resource
    private OldCoreCerCerContactMapper oldCoreCerCerContactMapper;

    /**
     * 处理经营范围的名称信息
     *
     * @param name 名称
     * @return 名称
     */
    public String resolveBusinessTypeName(String name) {
        if (name.contains("、")) {
            return name;
        }
        var wrapper = new LambdaQueryWrapper<OldCoreCerCerContact>()
                .likeLeft(OldCoreCerCerContact::getCerCercontactName, "、" + name)
                .last("limit 1");
        var po = oldCoreCerCerContactMapper.selectOne(wrapper);
        return po == null ? name : po.getCerCercontactName();
    }

}
